package com.ababa.consumerService.controller;

import com.ababa.common.RestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/info")
public class ServiceInfoController {

    private RestTemplate restTemplate;

    @Autowired
    public void setRestTemplate(RestTemplate restTemplate){
        this.restTemplate = restTemplate;
    }

    @RequestMapping(value = "/producer-info", method = RequestMethod.GET)
    public RestResponse<?> getProducerServiceInfo(){
        // producer-service为注册中心中服务的地址
        return restTemplate.getForObject("http://producer-service/producer/info",RestResponse.class);
    }

}
